<extend name="Base/common"/>
<block name="left"></block>
<block name="body">
	<div class="proDelBox" style="background: #FFF;">
		<img class="register-css3" src="__PUBLIC__/Futures/third/option/images/register.png" width="100%">
		<p class="proRegisterpde  phone_num  clearfix rebordercss3">
			<span class="icon-uniE914 proRegistericon1"></span>
			<input type="number" name="mobile" id="mobile" placeholder="手机号">
		</p>
		<p class="proRegisterpde rebordercss3 reg_pwd clearfix reg_password">
			<span class="icon-uniE913 proRegistericon2"></span>
			<input placeholder="密码" name="password" id="password" value="" type="password">
		</p>
		<p class="proRegisterpde rebordercss3 reg_repwd clearfix reg_password">
			<span class="icon-uniE913 proRegistericon3"></span>
			<input placeholder="确认密码" name="repassword" id="repassword" value="" type="password">
		</p>
		<p class="proRegisterpde rebordercss3 reg_code clearfix">
			<span class="icon-uniE912 proRegistericon4"></span>
			<input type="text" name="code" id="code" placeholder="验证码" style="width:100px;">
			<input type="submit" class="btn click" value="获取验证码" id="GetCode" >
		</p>
		<span class="msg"></span>
		<div class="xieyi ">
			<input class="proRegistercheckbox click rebordercss3" id="checkbox" name="check" checked="checked" type="checkbox">
			<label class="proRegisterlabel icon-uniE915 click" for="checkbox"></label>
			<span>我已阅读并同意</span>
			<a href="{:U('Agreement/agreement')}">《用户协议》</a>
		</div>
		<div style="padding: 0px 20px;"><input type="button" value="立即注册" class="reg_btn"></div>
	</div>
	<block name="script">
		<script type="text/javascript">
		
			$(document).ready(function(){
						/*密码框*/
				$(".reg_bar .reg_password").find("input[type='text']").focus(function() {
					var text_value = $(this).val();
					if (text_value == this.defaultValue) {
						var obj=$(this).parent(".reg_password")
						$(this).hide();
						obj.find("input[type='password']").show().focus();
					}
				});
				$(".reg_bar .reg_password").find("input[type='password']").blur(function() {
					var text_value = $(this).val();
					if (text_value == "") {
						var obj1=$(this).parent(".reg_password")
						$(this).hide();
						obj1.find("input[type='text']").show();
					}
				});

				// 获取验证码
				$("#GetCode").click(function(){
					var mobile=$('#mobile').val();
					var reg=/^1[3|4|5|7|8]\d{9}$/;
					if (reg.exec(mobile)==null) {
						$('.msg').html('手机号不匹配或为空');
						return false;
					}else{
						$('.msg').html('');
					}
					var url="{:U('User/send_verify')}";
					$.post(url,{mobile:mobile},function(data){
						if(data.status){
							setInt();
						}else{
							$(".msg").html(data.msg);
							$('#GetCode').addClass('click');
						}
					},'json')
				})
				var count=60;
				var curCount;
				var objTime;
				function setTime(){
					if (curCount==0) {
						clearInterval(objTime);
						$('#GetCode').removeAttr('disabled');
						$('#GetCode').css('background','#ff0000');
						$('#GetCode').val('重发验证码');
					}else{
						curCount--;
						$('#GetCode').val(curCount + "秒后重发")
					}
				}

				function setInt() {
					curCount=count;
					$('#GetCode').attr('disabled','true');
					$('#GetCode').removeClass('click');
					$('#GetCode').val(curCount + "秒后重发")
					objTime=setInterval(setTime,1000);
				}

			})
			$('.reg_btn').click(function(){
				var mobile=$('#mobile').val();
				var password=$('#password').val();
				var repassword=$('#repassword').val();
				var code=$('#code').val();
				var url="{:U('User/user_register_add')}";
				var reg=/^1[3|4|5|7|8]\d{9}$/;
				if(reg.exec(mobile)==null) {
					$('.msg').html('手机号不匹配或为空');
					return false;
				}
				if(password==''){
					$('.msg').html('密码不能为空');
					return false;
				}
				if(repassword==''){
					$('.msg').html('确认密码不能为空');
					return false;
				}
				if(password!=repassword){
					$('.msg').html('密码不相同');
					return false;
				}
				if(code==''){
					$('.msg').html('验证码不能为空');
					return false;
				}
				var hasChk = $('#checkbox').attr('checked');
				if(hasChk=='checked'){
					/*已选中*/
				}else{
					$('.msg').html('用户协议未选中');
					return false;
				}
				$.post(url,
						{
							phone:mobile,
							password:password,
							repassword:repassword,
							code:code,
						},function(data){
							if(data.status){
								$('.msg').html(data.msg);
								setTimeout(link_url(),2000);
							}else{
								$('.msg').html(data.msg);
							}
						},'json')


			})
			function link_url(){
				var url_href="{:U('Index/index')}";
				window.location.href=url_href;
			};
			//1px 解决
//			var metahtml='<meta name="viewport" content="initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5, user-scalable=no"><meta name="viewport" content="initial-scale=0.3333333333333333, maximum-scale=0.3333333333333333, minimum-scale=0.3333333333333333, user-scalable=no">';
			//$('head').prepend(metahtml);
			$(".xieyi").click(function(){
				var cked=$('#checkbox').attr('checked');
				if(cked=='checked'){
					$('.proRegisterlabel').removeClass('click');
					$('#checkbox').removeAttr('checked');
				}else{
					$('.proRegisterlabel').addClass('click');
					$('#checkbox').attr('checked','checked');
				}

			})
		</script>
	</block>

</block>
